package cn.kgc.watch.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;
import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Cart {
    private Integer id;
    private User user;
    private Double totalPrice;
    private Date createTime;
    private Date modifyTime;
    private List<CartShopping> cartShoppingList;
    private CartShopping cartShopping;

    public CartShopping getCartShopping() {
        return cartShopping;
    }

    public void setCartShopping(CartShopping cartShopping) {
        this.cartShopping = cartShopping;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Double getTotalPrice() {
        Double price=0.0;
        if(cartShoppingList!=null){
            for (CartShopping cartShopping : this.cartShoppingList) {
                price+=cartShopping.getTotalPrice();
            }
        }
        return price;
    }

    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public List<CartShopping> getCartShoppingList() {
        return cartShoppingList;
    }

    public void setCartShoppingList(List<CartShopping> cartShoppingList) {
        this.cartShoppingList = cartShoppingList;
    }

}
